﻿/* QF classbuilder for Enlib */
using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Logging;

#region SYS_License实体类
public class SYS_License
{
	private string m_LicData;
	
	public SYS_License ()
	{
		m_LicData="";
	}
	
	public string LicData
	{
		get{return m_LicData;}
		set{m_LicData=value;}
	}
}
#endregion

#region SYS_License管理类
public partial class LogicLayer
{
	public bool AddSYS_License(SYS_License theSYS_License)
	{
		try
		{
			Database db = DatabaseFactory.CreateDatabase("connStr");
			string sql = "insert into SYS_License (LicData) values (@LicData)";
			System.Data.Common.DbCommand cmd = db.GetSqlStringCommand(sql);
			
			db.AddInParameter(cmd, "@LicData", DbType.String, theSYS_License.LicData);
			
			db.ExecuteNonQuery(cmd);
			return true;
		}
		catch(Exception ex)
		{
			Logger.Write("AddSYS_License:" + ex.Message );
			return false;
		}
	}
	
	public SYS_License GetSYS_LicenseFromDataReader(IDataReader dataReader)
	{
		try
		{
			SYS_License result = new SYS_License();
			
			if (dataReader["LicData"] != null && dataReader["LicData"] != System.DBNull.Value )
				result.LicData = (string)dataReader["LicData"];
			
			return result;
		}
		catch(Exception ex)
		{
			Logger.Write("GetReaderSYS_License:" + ex.Message);
			return null;
		}
	}
	
	public SYS_License GetSYS_License()
	{
		try
		{
			Database db = DatabaseFactory.CreateDatabase("connStr");
			string sql = "select * From SYS_License where ";
			
			System.Data.Common.DbCommand cmd = db.GetSqlStringCommand(sql);
			
			SYS_License result = null;
			using (IDataReader dataReader = db.ExecuteReader(cmd))
			{
				if (dataReader.Read())
				{
					result = GetSYS_LicenseFromDataReader( dataReader );
				}
			}
			return result;
		}
		catch(Exception ex)
		{
			Logger.Write("GetSYS_License:" + ex.Message);
			return null;
		}
	}
	
	public bool DelSYS_License()
	{
		try
		{
			Database db = DatabaseFactory.CreateDatabase("connStr");
			string sql = "delete From SYS_License where ";
			
			System.Data.Common.DbCommand cmd = db.GetSqlStringCommand(sql);
			
			db.ExecuteNonQuery(cmd);
			return true;
		}
		catch(Exception ex)
		{
			Logger.Write("DelSYS_License:" + ex.Message);
			return false;
		}
	}
	
	public bool UpdateSYS_License(SYS_License theSYS_License)
	{
		try
		{
			Database db = DatabaseFactory.CreateDatabase("connStr");
			string sql = "update SYS_License set LicData=@LicData where ";
			System.Data.Common.DbCommand cmd = db.GetSqlStringCommand(sql);
			
			db.AddInParameter(cmd, "@LicData", DbType.String, theSYS_License.LicData);
			
			db.ExecuteNonQuery(cmd);
			return true;
		}
		catch(Exception ex)
		{
			Logger.Write("UpdateSYS_License:" + ex.Message);
			return false;
		}
	}
	
	public List<SYS_License> ListSYS_License()
	{
		try
		{
			Database db = DatabaseFactory.CreateDatabase("connStr");
			string sql = "select * from SYS_License";
			System.Data.Common.DbCommand cmd = db.GetSqlStringCommand(sql);
			
			 List<SYS_License> result = new  List<SYS_License>();
			using (IDataReader dataReader = db.ExecuteReader(cmd))
			{
				while (dataReader.Read())
				{
					SYS_License obj = GetSYS_LicenseFromDataReader( dataReader );
					if(obj != null)
						result.Add(obj);
				}
			}
			return result;
		}
		catch(Exception ex)
		{
			Logger.Write("ListSYS_License:" + ex.Message);
			return null;
		}
	}
	
}
#endregion